//
//  HWReadRecordCell.m
//  嗨文
//
//  Created by 响当当 on 2019/2/18.
//  Copyright © 2019年 dongzheng. All rights reserved.
//

#import "HWReadRecordCell.h"

@interface HWReadRecordCell()
@property (nonatomic, strong)UILabel *titleLabel;//标题
@property (nonatomic, strong)UIImageView *haiFriendImageView;//嗨书友
@property (nonatomic, strong)UIImageView *vipImageView;//是否是VIP
@property (nonatomic, strong)UIButton *hwLevelButton;//嗨等级
@property (nonatomic, strong)UIButton *connectBtn;//联系
@property (nonatomic, strong)UILabel *connectMATimeLabel;//扫码时间
@property (nonatomic, strong)UILabel *joinHaiTimeLabel;//加入嗨赚时间
@property (nonatomic, strong)UILabel *moneyLabel;//金额
@property (nonatomic, strong)UILabel *friendLabel;//嗨友

@end

@implementation HWReadRecordCell

- (UILabel *)titleLabel
{
    if (!_titleLabel)
    {
        _titleLabel = [HWUtilties creatLabelWithFrame:CGRectMake(16*kUIScaleBasePlus,18*kUIScaleBasePlus,0,15*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:LCHexColor(0x1F1F1F)
                                             textFont:16*kUIScaleBasePlus];
    }
    return _titleLabel;
}

- (UIImageView *)haiFriendImageView
{
    if (!_haiFriendImageView)
    {
        _haiFriendImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,20*kUIScaleBasePlus,36*kUIScaleBasePlus,11*kUIScaleBasePlus)];
        _haiFriendImageView.image = [UIImage imageNamed:@"book_friend"];
    }
    return _haiFriendImageView;
}

- (UIImageView *)vipImageView
{
    if (!_vipImageView)
    {
        _vipImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,20*kUIScaleBasePlus,27*kUIScaleBasePlus,11*kUIScaleBasePlus)];
        
    }
    return _vipImageView;
}

- (UIButton *)hwLevelButton
{
    if (!_hwLevelButton)
    {
        _hwLevelButton = [HWUtilties creatButtonWithFrame:CGRectMake(0,14*kUIScaleBasePlus,62*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                             textAligment:NSTextAlignmentRight
                                                     text:@"嗨赚Lv32"
                                                 textClor:[UIColor whiteColor]
                                                buttonBGC:[UIColor clearColor]
                                                 textFont:12*kUIScaleBasePlus
                                                   target:self
                                                   method:@selector(getMoneyClick)];
        [_hwLevelButton.titleLabel setFont:[UIFont boldSystemFontOfSize:9*kUIScaleBasePlus]];
        [_hwLevelButton setBackgroundImage:[UIImage imageNamed:@"earn_level"] forState:UIControlStateNormal];
        [_hwLevelButton setTitleEdgeInsets:UIEdgeInsetsMake(3,0,0,-15)];
    }
    return _hwLevelButton;
}

- (UIButton *)connectBtn
{
    if (!_connectBtn)
    {
        _connectBtn = [HWUtilties creatButtonWithFrame:CGRectMake(SCREEN_WIDTH-15*kUIScaleBasePlus-56*kUIScaleBasePlus,14*kUIScaleBasePlus,56*kUIScaleBasePlus,23*kUIScaleBasePlus)
                                          textAligment:NSTextAlignmentCenter
                                                  text:@"联系TA"
                                              textClor:LCHexColor(0x00A1FF)
                                             buttonBGC:[UIColor clearColor]
                                              textFont:11*kUIScaleBasePlus
                                                target:self
                                                method:@selector(connectClick)];
        _connectBtn.layer.masksToBounds = YES;
        _connectBtn.layer.cornerRadius = _connectBtn.frame.size.height/2;
        _connectBtn.layer.borderWidth = 1;
        _connectBtn.layer.borderColor = LCHexColor(0x00A1FF).CGColor;
    }
    return _connectBtn;
}

- (UILabel *)connectMATimeLabel
{
    if (!_connectMATimeLabel)
    {
        _connectMATimeLabel = [HWUtilties creatLabelWithFrame:CGRectMake(16*kUIScaleBasePlus,49*kUIScaleBasePlus,160*kUIScaleBasePlus,10*kUIScaleBasePlus)
                                                 textAligment:NSTextAlignmentLeft
                                                     textClor:LCHexColor(0x6E6E6E)
                                                     textFont:10*kUIScaleBasePlus];
    }
    return _connectMATimeLabel;
}

- (UILabel *)joinHaiTimeLabel
{
    if (!_joinHaiTimeLabel)
    {
        _joinHaiTimeLabel = [HWUtilties creatLabelWithFrame:CGRectMake(16*kUIScaleBasePlus,CGRectGetMaxY(self.connectMATimeLabel.frame)+8*kUIScaleBasePlus,160*kUIScaleBasePlus,10*kUIScaleBasePlus)
                                                 textAligment:NSTextAlignmentLeft
                                                     textClor:LCHexColor(0x6E6E6E)
                                                     textFont:10*kUIScaleBasePlus];
    }
    return _joinHaiTimeLabel;
}

- (UILabel *)moneyLabel
{
    if (!_moneyLabel)
    {
        _moneyLabel = [HWUtilties creatLabelWithFrame:CGRectMake(0,45*kUIScaleBasePlus,0,13*kUIScaleBasePlus)
                                                 textAligment:NSTextAlignmentLeft
                                                     textClor:LCHexColor(0xF54337)
                                                     textFont:16*kUIScaleBasePlus];
    }
    return _moneyLabel;
}

- (UILabel *)friendLabel
{
    if (!_friendLabel)
    {
        _friendLabel = [HWUtilties creatLabelWithFrame:CGRectMake(0,66*kUIScaleBasePlus,0,10*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:LCHexColor(0x6E6E6E)
                                             textFont:10*kUIScaleBasePlus];
    }
    return _friendLabel;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.haiFriendImageView];
        [self.contentView addSubview:self.vipImageView];
        [self.contentView addSubview:self.hwLevelButton];
        [self.contentView addSubview:self.connectBtn];
        [self.contentView addSubview:self.connectMATimeLabel];
        [self.contentView addSubview:self.moneyLabel];
        [self.contentView addSubview:self.joinHaiTimeLabel];
        [self.contentView addSubview:self.friendLabel];
    }
    return self;
}

#pragma mark - 获取数据
- (void)getDate:(HWCashRecordListModel *)model
{
    self.titleLabel.text = model.nickName;
    [self.titleLabel sizeToFit];
    
    NSString *haiFriendStr = [model.gender stringValue];
    NSString *vipStr = [model.isVip stringValue];
    NSString *haiLevel = model.agentLevelName;
    
    [self.haiFriendImageView setX:CGRectGetMaxX(self.titleLabel.frame)+10*kUIScaleBasePlus];
    
    if ([haiFriendStr isEqualToString:@"0"])
    {
        self.haiFriendImageView.image = [UIImage imageNamed:@"book_friend"];

    }
    else
    {
        self.haiFriendImageView.image = [UIImage imageNamed:@"book_friend"];
    }
//    if ([haiFriendStr isEqualToString:@"1"])
//    {
//        [self.haiFriendImageView setX:CGRectGetMaxX(self.titleLabel.frame)+10*kUIScaleBasePlus];
//        self.haiFriendImageView.hidden = NO;
//    }
//    else
//    {
//        self.haiFriendImageView.hidden = YES;
//    }
    
    [self.vipImageView setX:CGRectGetMaxX(self.haiFriendImageView.frame)+10*kUIScaleBasePlus];

    if ([vipStr isEqualToString:@"1"])
    {
        self.vipImageView.image = [UIImage imageNamed:@"vip_nactive"];
    }
    else
    {
        self.vipImageView.image = [UIImage imageNamed:@"vip_nonactive"];

    }
    
    self.hwLevelButton.hidden = NO;
    [self.hwLevelButton setX:CGRectGetMaxX(self.vipImageView.frame)+10*kUIScaleBasePlus];
    [self.hwLevelButton setTitle:haiLevel forState:UIControlStateNormal];
    
//    if ([haiLevel isEqualToString:@"1"])
//    {
//        self.hwLevelButton.hidden = NO;
//        [self.hwLevelButton setX:CGRectGetMaxX(self.vipImageView.frame)+10*kUIScaleBasePlus];
//    }
//    else
//    {
//        self.hwLevelButton.hidden = YES;
//    }
    
    self.connectMATimeLabel.text = [NSString stringWithFormat:@"扫码时间：%@",model.registerTime];
    [self.connectMATimeLabel sizeToFit];
    
    self.joinHaiTimeLabel.text = [NSString stringWithFormat:@"加入嗨赚：%@",model.joinAgentTime];
    [self.joinHaiTimeLabel sizeToFit];
    
    self.connectBtn.hidden = YES;
    
    NSString *str = [NSString stringWithFormat:@"+%@",[model.withdrawCash stringValue]];
    self.moneyLabel.attributedText = [str addAttriButedString:str
                                                        Color:LCHexColor(0xF54337)
                                                         Font:[UIFont systemFontOfSize:16*kUIScaleBasePlus]
                                                         rang:NSMakeRange(0,1)];
    [self.moneyLabel sizeToFit];
    [self.moneyLabel setX:SCREEN_WIDTH-16*kUIScaleBasePlus-self.moneyLabel.frame.size.width];
    
    self.friendLabel.text = [NSString stringWithFormat:@"%@个嗨友",model.agentLevelNo];
    [self.friendLabel sizeToFit];
    [self.friendLabel setX:SCREEN_WIDTH-16*kUIScaleBasePlus-self.friendLabel.frame.size.width];

}


#pragma mark - Method
//无用
- (void)getMoneyClick
{
    
}

- (void)connectClick
{
    
}
@end
